package 题目集.dfs;

import java.util.Scanner;

public class 字符串序号 {
    static int n;
    static int[] tar=new int[26];
    static int[] cur=new int[26];
    static int cnt=0;
    static boolean[] vis=new boolean[26];

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String line = sc.nextLine();
        n=line.length();
        for (int i = 0; i < n; i++) {
            tar[i]=line.charAt(i)-'a';
        }
        int ans = dfs(0);
        System.out.println(ans);
    }

    public static int dfs(int index){
        if(index==n){
            if (check()){
                return cnt;
            }
            cnt++;
            return -1;
        }

        for (int j = 0; j < n; j++) {
            if (!vis[j]){
                vis[j]=true;
                cur[index]=j;
                int res=dfs(index+1);
                if (res!=-1){
                    return res;
                }
                vis[j]=false;
            }
        }
        return -1;
    }

    public static boolean check(){
        for (int i = 0; i < n; i++) {
            if(tar[i]!=cur[i]){
                return false;
            }
        }
        return true;
    }
}
